import React,{useState} from 'react'

export default function App() {
  console.log('渲染')
  // console.log( useState(0))
  const [num,setNum] = useState(0)
  console.log(num)
  // console.log(useState(true))
  const [isDis, setisDis] = useState(true)

  const [obj, setobj] = useState({
    a:1,
    b:2,
    c:{
      a:1,
      b:2
    }
  })

  const [arry, setarry] = useState([1,2,3,4])
  // if(isDis){
  //   const [data, setdata] = useState(10)
  // }
  console.log(isDis)
  // console.log(num)
  const AddNum = ()=>{
   const c ={
    a:obj.c.a+ 1,
    b:3
    
   } 
    setobj({...obj,c})
  }
  const JNum = ()=>{
    const c ={
      a:obj.c.a -  1,
      b:1
    
     } 
     setobj({...obj,c})
    // setNum(num-1)
  }
  console.log(obj)
  return (
    <div>
     <div style={{display: isDis ? 'block' : "none"}}>
      <button onClick={
        AddNum
      }>增加</button>
       {/* {obj.a} */}
       {obj.c.a}
      <button onClick={
        JNum
      }>减少</button>
      </div>
      {arry}
      <button onClick={
       ()=>{
        // arry.push(4)
        setarry([...arry,6])
       }
      }>显示隐藏</button>
    </div>
  )
}
